package com.banmao.algorithm.No101To200.No116;


// 递归解法
public class Solution2 {

    public Node connect(Node root) {
        if(root == null) {
            return null;
        }

        recrusive(root.left, root.right);

        return root;

    }

    private void recrusive(Node left, Node right) {
        if(left == null || right == null) {
            return;
        }

        left.next = right;

        recrusive(left.left, left.right);
        recrusive(right.left, right.right);
        recrusive(left.right, right.left);

    }

}
